<template>
  <div class="content">
    <div class="phone lunbo">
      <img src="../assets/lunbo/m_banner.png" alt="">
    </div>
    <div class="top-lunbo">
      <el-carousel height="612px">
        <el-carousel-item v-for="(item, i) in 2" :key="item">
          <div class="img-box" v-if="i == 0">

            <img v-if="i == 0" src="@/assets/lunbo/home2.jpg" alt="">
          </div>
          <div class="img-box" v-if="i == 1">
            <img src="@/assets/lunbo/home1.jpg" alt="">
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="chanpin-box">
      <div class="chanpin-item banner-box">
        <div class="title">
          <h1>
            产品列表
          </h1>
          <h2>
            四度制冷 专注打造您满意的产品
          </h2>
          <span></span>
        </div>
        <div class="bottom-box">
          <div class="item-box">
            <div class="title-box">
              <h1>产品分类导航</h1>
              <h2>PRODUCT CENTER</h2>
            </div>
            <div class="item pc" v-for="(item, index) in LeftList" :key="index"
              @click="gotoChanpinList(item.record_id)">
              {{ item.title }}
            </div>
            <div class="phone item-box">
              <div class="item" v-for="(item, index) in LeftList" :key="index" @click="gotoChanpinList(item.record_id)">
                {{ item.title }}
              </div>
            </div>
            <div class="bottom">
              <div class="left">
                <h1>咨询热线：</h1>
                <h2>{{ webxinxi.tel1 }}</h2>
                <h2>{{ webxinxi.tel2 }}</h2>
              </div>
              <div class="img">
                <img src="../assets/ui/logo.png" alt="">
              </div>
            </div>
          </div>
          <div class="right pc" v-if="LeftList[0]">
            <div class="top-imgbox">
              <div class="left-img">
                <img :src="base64Img(LeftList[0].chanpin[0].img[0])" alt="">
              </div>
              <div class="message-box">
                <div class="item">
                  <h1>
                    {{ LeftList[0].chanpin[0].title }}
                  </h1>
                  <h2>
                    产品型号：{{ LeftList[0].chanpin[0].xinghao }}
                  </h2>
                  <h3>
                    {{ LeftList[0].chanpin[0].minText }}
                  </h3>
                  <div class="btn" @click="gotoChanpinXiangqing(LeftList[0].chanpin[0].id)">
                    查看详情
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="phone-box phone right">
            <div class="item-box">
              <div class="item" v-for="(item, index) in LeftList" :key="index" @click="
                gotoChanpinList(item.record_id)">
                <img :src="base64Img(item.img)" alt="">
                <h1>{{ item.title }}</h1>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 广告框 -->
    <div class="adbox pc">
      <div class="top-content ">
        <div class="top-left-content">

        </div>
        <div class="top-right-content">
          <div class="center-item">
            <div><img src="../assets/imgs/ui/1.png"></div>
            <div><img src="../assets/imgs/ui/2.png"></div>
            <div><img src="../assets/imgs/ui/3.png"></div>
          </div>
          <div class="right-span">
            <div>
              <div class="title">专属研发</div>
              <div class="text">拥有包括制冷、软件、设计等
                研发设计人员10多名，<br>能够根据客户需求，研发
                和持续改进低温操作台、低<br>温工作台、洁净工作台
                等产品，使得我们的产品始终保持其良好的性能。</div>
            </div>
            <div>
              <div class="title">生产规模</div>
              <div class="text">拥有1600平米的生产车间，具备下料成型、焊
                接、<br>安装调试等能力，是实力品牌制冷设备制造公司。</div>
            </div>
            <div>
              <div class="title">售后无忧</div>
              <div class="text">我们的服务从产品设计、现场测量勘查、沟通方案、<br>生产制
                造、售后服务的及时，贯穿整个过程。让您无<br>后顾之忧。</div>
            </div>
          </div>
        </div>
      </div>
      <div class="item-content">
        <div class="left">
          <div>
            实验室用低温操作台（工作台）、血液低温操作台（工作台）、医用洁净工作台、
            低温洁净工作台、低温配血台、血液配血台、低温操作台（工作台）价格、低温操
            作台（工作台）厂家
          </div>
        </div>
        <div class="right">
          <div>{{ webxinxi.tel1 }}</div>
          <div>{{ webxinxi.tel2 }}</div>
        </div>
      </div>
    </div>
    <div class="adbox-phone phone">
      <div class="item-box">
        <div class="item">
          <img src="../assets/imgs/ui/1.png">
          <h1>专属研发</h1>
          <h2>拥有包括制冷、软件、设计等
            研发设计人员10多名，能够根据客户需求，研发
            和持续改进低温操作台、低温工作台、洁净工作台
            等产品，使得我们的产品始终保持其良好的性能。</h2>
        </div>
        <div class="item">
          <img src="../assets/imgs/ui/2.png">
          <h1>生产规模</h1>
          <h2>拥有1600平米的生产车间，具备下料成型、焊
            接、安装调试等能力，是实力品牌制冷设备制造公司。</h2>
        </div>
        <div class="item">
          <img src="../assets/imgs/ui/3.png">
          <h1>售后无忧</h1>
          <h2>我们的服务从产品设计、现场测量勘查、沟通方案、<br>生产制
            造、售后服务的及时，贯穿整个过程。让您无后顾之忧。</h2>
        </div>
      </div>
    </div>


    <!-- 公司简介 -->
    <div class="jianjie ">
      <div class="pc banner-box">
        <div class="top-title">
          <div class="title">公司简介</div>
          <div class="span">以质量求发展 打造您满意的产品</div>
          <div class="div">
            <p></p>
          </div>
        </div>
        <div class="bottom-center">
          <div class="left-img">
            <img src="../assets/imgs/ui/chejian/sdab.png" alt="">
          </div>
          <div class="right-content">
            <div class="title">公司简介</div>
            <div class="text">山东四度制冷科技有限公司是一家有着十多年制冷设备制造经验的科技公司，专业提供实验室用低温
              操作台（工作台）、血液低温操作台（工作台）、医用洁净工作台、低温洁净工作台、低温配血台、
              血液配血台、等设备的研发生产，是一家具有雄厚研发生产能力及规模、高性价比的价格、完善售后
              服务的专业医疗制冷设备生产厂家。公司有数名制冷研发工程师，一直致力于实验室、生物公司、医
              疗机构、制药厂、食品加工等有温度需求控制和空气净化的场所用设备的研发和生产。经过多年的实
              践生产经验，质量过硬，深得用户好评。并且我们可以根据用户的具体需求，特别定制各种规格的设
              备。公司始终以“满足客户需求”为己任，以“质量就是生命”为核心，打造让客户满意的产品。</div>

            <div class="img-list">
              <div class="img-item">
                <img src="../assets/imgs/ui/chejian/bz.jpg" alt="">
                <p>包装车间</p>
              </div>
              <div class="img-item">
                <img src="../assets/imgs/ui/chejian/sc1.jpg" alt="">
                <p>生产车间</p>
              </div>
              <div class="img-item">
                <img src="../assets/imgs/ui/chejian/sc2.jpg" alt="">
                <p>生产车间</p>
              </div>
              <div class="img-item">
                <img src="../assets/imgs/ui/chejian/zz.jpg" alt="">
                <p>组装车间</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="news-box">
      <div class="center">
        <div class="left-box">
          <div class="top-box">
            <p>新闻中心</p>
            <span>关注我们了解公司最新动态！</span>
          </div>
          <div class="img-box">
            <div class="img">
              <img v-if="firstData.img" :src="base64Img(firstData.img)" alt="">
            </div>
            <div class="title-box">
              <div class="time">最新消息</div>
              <div class="title">{{ firstData.title }}</div>
              <div class="btn" @click="gotoXiangqing(1, firstData.newsid)">查看详情</div>
            </div>
          </div>
        </div>
        <div class="right-box">
          <div class="top-btn-box">
            <div @click="gotoNewsView()">公司新闻</div>
            <div @click="gotoNewsView()">行业知识</div>
          </div>
          <div class="item-box" v-for="(item, index) in newsList" :key="index">
            <div class="item" v-if="index <= 4" @click="gotoXiangqing(1, item.newsid)">
              <div class="phone"></div>
              <div class="left-index pc">
                {{ index + 1 }}
              </div>
              <div class="title">
                {{ item.title }}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { getLeftList, getNewsList, getWebXinxi } from '@/api/viewapi.js'
import { onMounted, ref, reactive } from 'vue'
import { base64Img } from '@/tools/tools.js'
import router from '@/router/index.js';

const LeftList = ref([])
const LeftList2 = ref([])
const newsList = ref([])
const firstData = ref({})
const webxinxi = ref({})

// 左侧列表
const __getLeftData = () => {
  getLeftList().then((res) => {
    LeftList.value = res.data.data
    console.log('左侧信息', res);
    dataReact()
  })
}

// 获取新闻中心
const _getNewsList = () => {
  getNewsList().then((res) => {
    console.log('新闻列表', res);
    newsList.value = res.data.newslist
    firstData.value = res.data.newslist[0]

  })
}

// 获取网站信息
const _getWebXinxi = () => {
  getWebXinxi().then((res) => {

    console.log('网站信息', res);
    webxinxi.value = res.data.data
  })
}

// 跳转详情
const gotoXiangqing = (checkid, newsid) => {
  router.push({
    path: '/newsmessage', query: {
      checkid: checkid, newsid
    }
  })
}
// 跳转详情
const gotoChanpinList = (id) => {
  router.push({ path: '/chanpinlist', query: { id: id } })
}
// 跳转
const gotoChanpinXiangqing = (id) => {
  router.push({ path: '/chanpincontent', query: { id: id } })
}


// 跳转新闻页面
const gotoNewsView = () => {
  router.push({ path: '/news' })
}

// 轮播图数据处理
const dataReact = () => {
  let data = LeftList.value
  let pushData = []
  let item = []
  for (let i = 0; i < data.length; i++) {

    item.push(data[i])

    if (item.length === 6) {
      pushData.push({ item })
      item = []
    }
  }

  // 如果最后剩下不足 3 个元素，仍然需要推入
  if (item.length > 0) {
    pushData.push({ item });
  }

  LeftList2.value = pushData
  console.log('最后结果', pushData);
}

// 获取新闻列表


onMounted(() => {
  __getLeftData()
  _getNewsList()
  _getWebXinxi()
});

</script>
<style lang="scss" scoped>
// 取消显示手机端 显示pc端
@media (min-width: 800px) {
  .phone {
    display: none;
  }

  .adbox-phone {
    display: none;
  }

  .content {
    .top-lunbo {

      .img-box {
        position: relative;

        .title {
          position: absolute;
          left: 200px;
          top: 280px;
          color: white;

          p {
            font-size: 22px;
            font-weight: 400;
          }

          span {
            font-size: 67px;
            font-weight: 700;
            line-height: 140px;

          }

          h1 {
            font-size: 18px;
            line-height: 40px;
          }
        }
      }

    }

    .chanpin-box {
      padding: 40px 0;
      background-color: #ffffff;

      .chanpin-item {

        .title {
          text-align: center;
          font-size: 16px;

          h1 {
            font-weight: 800;
            font-size: 34px;
          }

          h2 {
            line-height: 40px;
          }

          span {
            margin: 0 auto;
            display: block;
            height: 4px;
            width: 70px;
            background-color: #00a0e9;
          }
        }
      }

      .bottom-box {
        display: flex;
        justify-content: space-between;
        margin-top: 20px;

        .item-box {
          padding: 20px 0;
          width: 240px;
          border: 2px solid #007dc4;

          .title-box {
            padding-left: 10px;
            padding-bottom: 40px;

            h1 {
              font-size: 26px;
            }

            h2 {
              font-size: 12px;
              font-weight: 400;
              color: rgb(136, 136, 136);
            }

          }

          .item {
            padding-left: 10px;
            line-height: 46px;
            border-bottom: 1px solid #007dc4;
            cursor: pointer;
          }

          .bottom {
            display: flex;
            padding: 20px 10px;

            .img {
              margin-left: 20px;

              img {
                width: 80px;
              }
            }
          }
        }

        .right {
          padding: 0 40px 0 40px;

          .top-imgbox {
            width: 1100px;
            height: 500px;
            background-image: url('../assets/ui/sdb.png');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            display: flex;
            justify-content: space-between;
            padding: 40px;

            .left-img {
              img {
                width: 600px;
                height: 500px;
              }
            }

            .message-box {
              padding: 0 20px;

              .item {
                h1 {
                  line-height: 40px;
                  font-size: 30px;
                }

                h2 {
                  line-height: 36px;
                }

                h3 {
                  line-height: 38px;
                  overflow: hidden;
                  height: 340px;
                }

                .btn {
                  margin-top: 10px;
                  padding: 20px;
                  border: 1px solid white;
                  width: 100px;
                  text-align: center;
                  border-radius: 20px;
                  background-color: #0093e8;
                  color: white;
                  cursor: pointer;
                }
              }
            }
          }
        }
      }
    }

    .adbox {
      margin: 0 auto;

      .top-content {
        display: flex;
        width: 100%;

        .top-left-content {
          width: 50%;
          height: 526px;
          background-image: url(../assets/imgs/ui/sdy.png);
          background-repeat: no-repeat;
          background-position: center;
          background-size: cover;
        }

        .top-right-content {
          height: 526px;
          width: 50%;
          position: relative;
          background-color: #00a0e9;
          color: white;

          .center-item {
            position: absolute;
            left: -44px;
            display: flex;
            height: 526px;
            justify-content: space-around;
            flex-direction: column;
          }

          .right-span {
            margin-left: 100px;
            height: 100%;
            display: flex;
            justify-content: space-around;
            flex-direction: column;

            .title {
              font-weight: 700;
              font-size: 22px;
            }

            .text {
              line-height: 24px;
            }
          }
        }
      }

      .item-content {
        background-image: url(../assets/imgs/ui/sdsanj.png);
        background-repeat: no-repeat;
        background-position: center;
        background-size: center;
        max-width: 1920px;
        margin: 0 auto;
        height: 200px;
        display: flex;

        .left {
          padding: 74px;
          width: 920px;
          line-height: 30px;
          font-size: 18px;
          color: white;
          font-weight: 700;

        }

        .right {
          padding: 50px 0;
          margin-left: 240px;
          font-size: 30px;
          color: white;
          font-weight: 700;
        }
      }
    }

    .jianjie {
      margin-top: 20px;

      .pc {
        .top-title {
          padding: 0 0 20px 0;
          text-align: center;

          .title {
            font-size: 32px;
            font-weight: 700;
          }

          .span {
            margin-top: 10px;
          }

          .div {
            display: flex;
            justify-content: center;
            margin-top: 10px;

            p {
              display: block;
              width: 110px;
              height: 4px;
              background-image: linear-gradient(to right, rgb(0, 109, 196), rgb(28, 189, 240));

            }
          }
        }

        .bottom-center {
          display: flex;

          .left-img {
            width: calc(50% - 20px);
            padding: 10px;
          }

          .right-content {
            padding: 10px 10px;

            .title {
              font-size: 22px;
              color: rgb(7, 157, 227);
            }

            .text {
              width: 750px;
              font-size: 16px;
              line-height: 28px;
            }

            .img-list {
              padding: 30px 50px;
              display: flex;


              .img-item {
                width: 160px;

                img {
                  width: 150px;
                }

                p {
                  text-align: center;
                }
              }
            }
          }
        }
      }
    }

    .news-box {
      padding: 100px 0;

      .center {
        max-width: 1400px;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;

        .left-box {
          .top-box {
            padding-bottom: 20px;

            p {
              font-weight: 400;
              font-size: 46px;
              margin-bottom: 10px;
            }

            span {}
          }

          .img-box {
            display: flex;
            justify-content: space-between;
            width: 840px;
            height: 500px;
            background-color: wheat;
            transition: transform 0.3s ease, background-color 0.3s ease;

            .img {
              width: 500px;
              height: 500px;
              background-color: #dbf3ff;
              flex-direction: column;
              display: flex;
              justify-content: center;

              img {
                width: 100%;
              }

            }

            .title-box {
              z-index: 99;
              width: 340px;
              background-color: #ebf3f7;
              padding: 80px 40px 40px 40px;

              .time {
                font-size: 26px;
                margin-bottom: 40px;
                font-weight: 200;
              }

              .title {

                line-height: 34px;
                font-weight: 800;
                font-size: 22px;
                margin-bottom: 20px;
              }

              .btn {
                padding: 16px 10px;
                border: 1px solid white;
                width: 100px;
                text-align: center;
                border-radius: 10px;
                color: white;
                background-color: #00a0e9;
                cursor: pointer;
                transition: transform 0.3s ease, background-color 0.3s ease;

              }

              .btn:hover {
                background-color: orange;
              }

            }
          }

          .img-box:hover {
            z-index: -1;
            transform: scale(1.01);
          }
        }

        .right-box {
          .top-btn-box {
            display: flex;
            padding-bottom: 60px;

            div {
              padding: 14px 60px;
              border: 1px solid rgb(0, 0, 0);
              margin-left: 40px;
              border-radius: 10px;
              transition: transform 0.3s ease, background-color 0.3s ease;
              cursor: pointer;
            }

            div:hover {
              background-color: #00a0e9;
              color: white;
              border: 1px solid rgb(255, 255, 255);

            }
          }

          .item-box {
            .item {
              width: 100%;
              background-color: #ffffff;
              display: flex;
              border: 1px solid #ebf3f7;
              margin-bottom: 40px;
              transition: transform 0.3s ease, background-color 0.3s ease;

              .left-index {
                margin-right: 40px;
                padding: 20px 30px;
                height: 100%;
                background-color: #ebf3f7;
              }

              .title {
                line-height: 60px;
                overflow: hidden;
                white-space: nowrap;
                width: 390px;
                padding-right: 30px;
              }
            }

            .item:hover {
              border: 1px solid #00a0e9;
              cursor: pointer;
              transform: scale(1.01);

              .left-index {
                background-color: #00a0e9;
                color: white;
              }
            }
          }
        }
      }
    }
  }
}

// 取消显示pc端 显示手机端
@media screen and (max-width: 799px) {
  .pc {
    display: none;
  }

  .content {
    .phone {
      img {

        margin-top: 2px;

      }

      img {
        width: 100%;
      }
    }

    .top-lunbo {
      display: none;
    }

    .chanpin-box {
      .chanpin-item {
        .title {
          text-align: center;

          h1 {
            font-size: 20px;
            font-weight: 800;
            color: #00a0e9;
          }

          h2 {
            margin-bottom: 10px;
            font-size: 12px;
          }

          span {
            margin: 0 auto;
            display: block;
            height: 4px;
            width: 70px;
            background-color: #00a0e9;
          }
        }


        .bottom-box {
          .item-box {
            .title-box {
              display: none;
            }

            .pc {
              display: none;
            }

            .item-box {
              margin-top: 10px;
              display: grid;
              grid-template-columns: repeat(4, 1fr);
              /* 创建4列，每列占1fr */
              gap: 2px;

              /* 设置列与列之间的间距 */
              .item {
                padding: 14px 0;
                font-size: 14px;
                text-align: center;
                background-color: #00a0e9;
                color: white;
              }
            }

            .bottom {
              display: none;

              .left {
                display: none;
              }
            }
          }

          .phone-box {
            margin: 10px 0;

            .item-box {
              display: grid;
              grid-template-columns: repeat(2, 1fr);
              gap: 4px;

              .item {
                background-color: #00a0e9;

                img {
                  width: 100%;
                }

                h1 {
                  padding: 10px 0;
                  text-align: center;
                  color: white;
                }
              }
            }
          }
        }
      }
    }

    .adbox-phone {
      margin-top: 40px;

      background-image: url(../assets/home/imgs/sdy.png);
      background-repeat: no-repeat;
      background-position: center;
      background-size: center;

      .item-box {
        display: flex;
        justify-content: space-around;
        padding: 40px 0;
        background-color: rgba(0, 0, 0, 0.5);

        .item {
          width: calc((100vw / 3) - 40px);
          color: white;
          text-align: center;

          img {
            width: 70px;

          }
        }
      }
    }

    .jianjie {
      img {
        width: 100%;
      }

      padding: 20px 0;

      .top-title {
        .title {
          text-align: center;
          font-size: 26px;
          font-weight: 800;
        }

        .span {
          text-align: center;
          font-size: 14px;
        }

        .div {
          margin-top: 10px;
          display: flex;
          justify-content: center;

          p {
            height: 4px;
            width: 80px;
            background: #0093e8;
          }
        }
      }

      .bottom-center {

        .left-img {}

        .right-content {
          margin-top: 10px;
          margin-bottom: 10px;

          .title {
            display: none;
          }

          .img-list {
            display: none;
          }
        }
      }
    }

    .news-box {
      .center {
        .left-box {
          .top-box {
            text-align: center;

            p {
              font-weight: 800;
              font-size: 24px;
            }

            span {
              font-size: 14px;
            }
          }

          .img-box {
            margin-top: 10px;

            .img {
              img {
                width: 100%;
              }
            }

            .title-box {
              display: none;
            }
          }
        }

        .right-box {
          .top-btn-box {
            margin-top: 10px;
            display: flex;
            justify-content: space-around;

            div {
              padding: 10px;
              background-color: #00a0e9;
              border-radius: 10px;
              font-size: 22px;
              color: white;
            }
          }

          .item-box {
            margin-top: 10px;
            display: flex;

            .item {
              display: flex;
              padding: 6px;

              .phone {
                margin-top: 6px;
                background-color: #00a0e9;
                width: 10px;
                height: 10px;
                margin-right: 10px;
              }
            }
          }
        }
      }
    }
  }
}
</style>